<!--
 * @Description: 
 * @Version: 2.0
 * @Autor: wsh
 * @Date: 2023-06-20 10:13:27
 * @LastEditors: uphldjx 1373577124@qq.com
 * @LastEditTime: 2024-03-15 18:29:09
-->
<template>
  <BaseContainer>
    <aplid-base-crud ref="crud" class="w-100" v-bind="baseConfig" :paramsObj="paramsObj">
      <template v-slot:DetailDialog="{ row, show }">
        <Detail
          @rechange="handleOperate"
          @refresh="handleRefresh"
          :api="baseConfig.api"
          v-if="show"
          :nowRowData="row">
        </Detail>
      </template>
      <template v-slot:EditDialog="{ row, show }">
        <Edit
          @rechange="handleOperate"
          @refresh="handleRefresh"
          :api="baseConfig.api"
          :module="paramsObj.module"
          v-if="show"
          :nowRowData="row">
        </Edit>
      </template>
      <template v-slot:addDialog="{ row, show }">
        <Add
          @rechange="handleOperate"
          @refresh="handleRefresh"
          :api="baseConfig.api"
          v-if="show"
          :module="paramsObj.module"
          :nowRowData="row">
        </Add>
      </template>
    </aplid-base-crud>
  </BaseContainer>
</template>

<script setup lang="ts">
import { baseConfig } from './config'
import Detail from './Detail/index.vue'
import Edit from './Edit/index.vue'
import Add from './Add/index.vue'
import { useRoute } from 'vue-router';
import {getStore} from '@/utils/store'

let props = defineProps(
  {
    module:{
      type:[Number,String],
      default:1
    }
  }
)
let userInfo = getStore('userInfo')
const route = useRoute()

const crud = ref()
const paramsObj = ref(
  {
    code: 3005,
		module:1,
    moduleLabel:'一站办',
    creditCode:userInfo.organizationId!=1?userInfo.organizationId:undefined
  }
)
// 安全监管
if(route.query.module||route.query.module=='0'){
  paramsObj.value.module = Number(route.query.module)
  paramsObj.value.moduleLabel = '安全监管'
}
// 宁享
if(props.module==0){
  paramsObj.value.module = undefined
  paramsObj.value.moduleLabel = undefined
}
const handleRefresh = () => {
  nextTick(() => {
    crud.value.refreshChange()
  })
}

const handleOperate = (type, row, title) => {
  nextTick(() => {
    crud.value.handleOperate(type, row, title)
  })
}
</script>

<style scoped></style>